package br.com.werp.regras.suporte.integracao;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.ResourceBundle;

import br.com.werp.regras.geral.ErroPadrao;
import br.com.werp.regras.geral.integracao.MasterDAO;
import br.com.werp.regras.geral.util.Constantes;
import br.com.werp.regras.geral.vos.suporte.ManutencaoVO;
import br.com.werp.regras.geral.vos.tabelas.Manutencao;

public class ManutencaoDAO extends MasterDAO{

	private static ManutencaoDAO manutencaoDAO;
	
	private ManutencaoDAO(String banco) throws Exception {
		super(banco);
		
	}
	
	 public static ManutencaoDAO getManutecaoDAO() throws Exception {
			if(manutencaoDAO == null) {
				ResourceBundle bundle = ResourceBundle.getBundle(Constantes.CONFIG);
	            manutencaoDAO = new ManutencaoDAO(bundle.getString(Constantes.BANCO));
	                        
			}
			
			return manutencaoDAO;
		}


	public List pesquisarManutencaoVO(ManutencaoVO manutencaoVO, Object key) throws Exception {
		Connection connection = null;
		if(key != null){
			connection = validarTransacao(key);
		} else {
			connection = getConexao();
		}
		try {
			return pesquisarVO(connection, manutencaoVO,"","manutencao",ManutencaoVO.EXCLUIDAS);
			
		} finally {
			if(key == null) {
				liberaConeccao(connection);
			}
		}
		
	}
	
	public List pesquiarManutencaoVO(ManutencaoVO manutencaoVO) throws Exception {
		return pesquisarManutencaoVO(manutencaoVO, null);
	}

	public void excluirManutencaoVO(Manutencao manutencao, Object key) throws Exception {
		Connection connection = validarTransacao(key);
		excluirVO(connection, manutencao);
	}
	
	

}
